﻿@using System.Globalization
@using Q42.DbTranslations.ViewModels
@model CultureIndexViewModel
@{
    Layout.Title = "Database translations";
    Script.Require("jQuery").AtHead();
}

<div class="content">  
  <h2>@T("Import translations from orchardproject.net")</h2>
  <p>@T("The newest version of translations is automatically downloaded from www.orchardproject.net and installed into the database.")</p>
  <table class="items">
    <th>@T("Culture")</th>
    <th>@T("Action")</th>
    @foreach (var translation in Model.TranslationStates.OrderBy(c => c.Key))
    {
      var culture = CultureInfo.GetCultureInfoByIetfLanguageTag(translation.Key);
      <tr>
        <td>
          @Html.ActionLink(
              culture.IetfLanguageTag + " - " + culture.DisplayName,
              "Culture",
              new { culture = culture.Name })
        </td>
        <td>
          <a href="@Url.Action("ImportLiveOrchardPo", new { culture = culture })">@T("Click here to fill this culture using a *.po.zip file from www.orchardproject.net.")</a>
        </td>
      </tr>
    }
  </table>
</div>

<p>&nbsp;</p>
  
<div class="content">
  @using (Html.BeginForm(new { action = "ImportCurrentPos" }))
  {
    @Html.AntiForgeryTokenOrchard()
    <h2>@T("Import existing *.po files")</h2>
    <p>@T("Already have translation po files installed? Import them into the database!")</p>
    <label><input type="checkbox" name="overwrite" value="true" /> overwrite existing values</label>
    <input type="submit" class="button" value="@T("Import!")" />
  }
</div>
<p>&nbsp;</p>


<div class="content">
    <h2>@T("Generate from source")</h2>
    <p>@T("Developing a module and want to add new translations to the database?<br />Existing translations will not be altered, only new translatable strings will be added.")</p>
    @Html.ActionLink(T("Generate from source - whole system").Text, "FromSource", null, new { @class = "button" })
    <p>@T("Or a module:")</p>
    <p>
        <form action="@Url.Action("FromFeature")" method="get">
            <input type="hidden" name="type" value="module" />
            <select id="modules" name="path">
                @foreach (var module in ViewBag.Modules)
                {
                    <option value="@module.Path">@module.Name</option>
                }
            </select>
            <input type="submit" class="button" name="submit" value="@T("Go")" />
        </form>
    </p>
    <p>@T("Or a theme:")</p>
    <p>
        <form action="@Url.Action("FromFeature")" method="get">
            <input type="hidden" name="type" value="theme" />
            <select id="themes" name="path">
                @foreach (var theme in ViewBag.Themes)
                {
                    <option value="@theme.Path">@theme.Name</option>
                }
            </select>
            <input type="submit" class="button" name="submit" value="@T("Go")" />
        </form>
    </p>
</div>
  
<p>&nbsp;</p>
  
<div class="content">
  <h2>@T("Upload a new or updated translation file"):</h2>
  <p>@T("The community is constantly adding new languages and translations, downloadable at <a target=\"_blank\" href=\"http://www.orchardproject.net/localize\">orchardproject.net/localize</a>. You can import the newest version of these *.po.zip files here.")</p>
  <form action="@Url.Action("Upload")" method="post" enctype="multipart/form-data">
  @Html.AntiForgeryTokenOrchard()
  <input type="file" class="fileupload" name="pofile" />
  <input type="submit" class="button" name="submit" value="@T("Upload")" />
  </form>
</div>